package com.huawei.saashousekeeper.config;

import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableDefault;

/**
 * 保存当前租户标识
 *
 * @since 2022-02-14
 */
public class TenantContext {

    private static final HystrixRequestVariableDefault<String> TENANT_KEY = new HystrixRequestVariableDefault<>();

    public static String get() {
        return TENANT_KEY.get();
    }

    public static void set(String key) {
        HystrixRequestContext.initializeContext();
        TENANT_KEY.set(key);
    }

    public static void remove() {
        TENANT_KEY.remove();
    }
}
